package com.zhangln.mountbuzhou.controller;

import com.zhangln.mountbuzhou.dto.BaseResponse;
import com.zhangln.mountbuzhou.dto.request.UserReq;
import com.zhangln.mountbuzhou.service.AuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sherry
 * @description
 * @date Create in 2020/4/27
 * @modified By:
 */
@RestController
@RequestMapping("/auth")
@Slf4j
public class AuthController {

    private final AuthService authService;

    public AuthController(AuthService authService) {
        this.authService = authService;
    }

    /**
     * 获取token
     *
     * @param userReq
     * @return
     */
    @PostMapping(value = "/token", params = "type=get")
    public BaseResponse getToken(@Validated UserReq userReq) {
        BaseResponse baseResponse = authService.getToken(userReq.getUsername(),userReq.getPassword());
        return baseResponse;
    }

}
